//
//  LGPersonalSelectView.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/2/15.
//

#import "LGLineTitleTipView.h"

@interface LGLineTitleTipView()
/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)UILabel *contentLabel;

@end

@implementation LGLineTitleTipView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubView];
    }
    return self;
}

-(void)setType:(NSString *)type{
    _type = type;
    if([self.type isEqualToString:@"text"]){
        [self addSubview:self.contentLabel];
        [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.tipView.mas_left);
            make.left.equalTo(self.titleLabel.mas_right).offset(viewPix(10));
            make.centerY.equalTo(self);
        }];
    }else{
        [self addSubview:self.imageView];
        [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.tipView.mas_left).offset(-viewPix(3));
            make.width.height.equalTo(@(viewPix(44)));
            make.centerY.equalTo(self);
        }];
    }
}

-(void)setTitle:(NSString *)title{
    _title = title;
    self.titleLabel.text = title;
}

-(void)setContent:(NSString *)content{
    _content = content;
    NSString *textColor = content.length>0?@"#606266":@"#909399";
    self.contentLabel.textColor = [UIColor colorWithString:textColor];
    self.contentLabel.text = content.length>0?content:@"请选择";
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    [self addSubview:self.titleLabel];
    [self addSubview:self.tipView];
    [self addSubview:self.lineView];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(viewPix(16));
        make.centerY.equalTo(self);
        make.width.equalTo(@(viewPix(140)+iPadMargin(50)));
    }];
    [self.tipView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-viewPix(16));
        make.width.height.equalTo(@(viewPix(12)));
        make.centerY.equalTo(self);
    }];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(viewPix(16));
        make.right.equalTo(self).offset(-viewPix(16));
        make.bottom.equalTo(self);
        make.height.equalTo(@(0.5));
    }];
}

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _titleLabel;
}

-(UILabel *)contentLabel{
    if(!_contentLabel){
        _contentLabel = [UILabel lableWithText:@"请选择" colorString:@"#909399" textFont:LGFont(15) textAlignment:NSTextAlignmentRight lines:2];
    }
    return _contentLabel;
}

-(UIImageView *)imageView{
    if(!_imageView){
        _imageView = [[UIImageView alloc]initWithImage:defaultDoctorPic];
        _imageView.cornerRidus = viewPix(22);
    }
    return _imageView;
}

-(UIImageView *)tipView{
    if(!_tipView){
        _tipView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"grayTip12"]];
    }
    return _tipView;
}

-(UIView *)lineView{
    if(!_lineView){
        _lineView = [[UIView alloc]init];
        _lineView.backgroundColor = [UIColor colorWithString:@"#E8E8E8"];
    }
    return _lineView;
}

@end
